<script setup lang="ts">
// 泛型
/*let test = <T>(arg: T): T => {
  return arg;
};
console.log(test<string>("1"));
console.log(test<number>(2));
console.log(test<boolean>(true));
console.log(test<any>(3));
console.log(test<unknown>(4));
console.log(test<void>());*/

/*let createArray = (count: number, value: any): any[] => {
  let arr: any[] = [];// 定义一个数组 数组初始化
  for (let i = 0; i < count; i++) {
    arr.push(value)
  }
  return arr;
}
let arr = createArray(3, 666);
console.log(arr);*/
// T类型 K key V value
/*let createArray = <T>(count: number, value: T): T[] => {
  let arr: T[] = [];
  for (let i = 0; i < count; i++) {
    arr.push(value);
  }
  return arr;
}
let arr = createArray<number>(5, 777);
console.log(arr);
console.log(arr[0].toFixed(2));*/
//多个泛型 K V

//泛型接口
interface Department{
 deptId:number,
 deptName:string,
 empList:[{empId:number,empName:string}]
}

interface Empoyee<T>{
  id: number,
  name: string,
  dept: T
  department: T
}

let emp : Empoyee<Department>;
emp = {
  id: 1,
  name: "张三",
  dept:{
    deptId:1001,
    deptName:"研发部",
    empList:[{empId:1001,empName:"张三"}]
  },
  department:{
    deptId:1002,
    deptName:"财务部",
    empList:[{empId:1002,empName:"李四"}]
  }
}
console.log(emp);


</script>

<template>

</template>

<style scoped>

</style>